package com.zhou.combine.security.config;

import com.google.common.collect.Lists;
import org.springframework.context.ApplicationContext;
import org.springframework.security.web.FilterInvocation;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

import javax.servlet.FilterChain;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Field;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Test
 *
 * @author zhouxianfeng
 * @date 2021-1-14
 */
public class Test {

    private ApplicationContext applicationContext;




    public static void main(String[] args) {
        List<String> list= Lists.newArrayList("1","2","3");
        List<String> collect = list.stream().map(t -> {
            if (t.equals("2")) {
                return null;
            } else {
                return t;
            }
        }).filter(t->t!=null).collect(Collectors.toList());
        System.out.println(collect);
    }

    public void test1(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain,Object object) throws Exception {
        FilterInvocation invocation= (FilterInvocation) object;
        invocation.getHttpRequest();


        RequestMappingHandlerMapping requestMappingHandlerMapping = (RequestMappingHandlerMapping) applicationContext.getBean("requestMappingHandlerMapping");
        HttpServletRequest request=(HttpServletRequest) servletRequest;

        Field mappingRegistry = RequestMappingHandlerMapping.class.getDeclaredField("mappingRegistry");
        mappingRegistry.setAccessible(true);

    }



}
